import request from '@/utils/request'

/**
 * 添加购物车
 * @param {string} skuId 商品id
 * @param {string} skuNum 商品数量
 * @returns
 */
export const reqGetShop = (skuId, skuNum) => {
	return request({
		method: 'POST',
		url: `/cart/addToCart/${skuId}/${skuNum}`,
	})
}

/**
 * 获取购物车列表
 * @returns
 */
export const reqGetCarList = () => {
	return request({
		method: 'GET',
		url: '/cart/cartList',
	})
}

/**
 * 单选框
 * @param {number} skuId 商品id
 * @param {number} isChecked  1 | 0
 * @returns
 */
export const reqGetCart = (skuId, isChecked) => {
	return request({
		method: 'GET',
		url: `/cart/checkCart/${skuId}/${isChecked}`,
	})
}

/**
 * 批量选择 全选
 * @param {Array} skuIdList
 * @param {Number} isChecked
 * @returns
 */
export const reqBatchCheckCart = (skuIdList, isChecked) => {
	return request({
		method: 'POST',
		url: `/cart/batchCheckCart/${isChecked}`,
		data: skuIdList,
	})
}

/**
 * 删除单个商品
 * @param {Number} skuId  商品Id
 */
export const reqDelCart = (skuId) => {
	return request({
		method: 'DELETE',
		url: `/cart/deleteCart/${skuId}`,
	})
}

/**
 * 批量删除
 * @param {Array} skuIdList
 * @returns
 */
export const reqBatchDelCart = (skuIdList) => {
	return request({
		method: 'POST',
		url: '/cart/batchDeleteCart',
		data: skuIdList,
	})
}
